package com.winsdom.entity.customer;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.*;
import java.util.List;

/**
 * 个人客户信息更新请求
 * 用于接收更新个人客户信息的请求参数
 */
@Data
@Schema(name = "CustomerPersonalUpdateRequest", description = "个人客户信息更新请求")
public class CustomerPersonalUpdateRequest {

    @Schema(description = "客户ID", example = "5", required = true)
    @NotNull(message = "客户ID不可为空")
    private Long customerId;

    @Schema(description = "客户类型", example = "3", required = true)
    @NotNull(message = "客户类型不可为空")
    @Min(value = 3, message = "客户类型无效")
    @Max(value = 3, message = "客户类型无效")
    private Integer customerType;

    @Schema(description = "客户名称", example = "测试用户2")
    @Size(min = 2, max = 50, message = "客户名称长度为2至50个字符")
    @Pattern(regexp = "^[\\s\\S]{4,50}$", message = "客户名称长度为4至50个字符")
    private String customerName;

    @Schema(description = "客户手机号", example = "13888888885")
    @Pattern(regexp = "^1\\d{10}$", message = "手机号格式不正确，应为11位数字且以1开头")
    private String mobilePhone;

    @Schema(description = "电子邮箱", example = "ces2@example.com")
    @Email(message = "邮箱格式不正确")
    @Size(max = 100, message = "邮箱长度不能超过100个字符")
    private String email;

    @Schema(description = "证件类型", example = "居民身份证")
    @Size(max = 20, message = "证件类型长度不能超过20个字符")
    private String idType;

    @Schema(description = "证件号码", example = "11010519491231002X")
    @Size(min = 6, max = 30, message = "证件号码长度为6至30个字符")
    private String idNumber;

    @Schema(description = "证件图片地址", example = "/upload/idcard/2.jpg")
    @Size(max = 255, message = "证件图片地址长度不能超过255个字符")
    private String idImagePath;

    @Schema(description = "联系人信息列表", example = "[{\"contactName\":\"王五\",\"contactMobile\":\"13567664888\",\"contactEmail\":\"wangwu@qq.com\",\"receiveProperties\":[\"海王星大厦\"]}]")
    @Valid
    @Size(max = 5, message = "联系人最多5个")
    private List<ContactInfo> contactInfos;

    @Data
    @Schema(name = "CustomerPersonalUpdateRequest.ContactInfo", description = "个人客户联系人信息（更新用）")
    public static class ContactInfo {

        @Schema(description = "客户ID", hidden = true)
        private Long customerId;

        @Schema(description = "联系人ID", example = "1", required = true)
        private Long contactId;

        @Schema(description = "联系人姓名", example = "王五")
        @Size(min = 2, max = 50, message = "联系人姓名长度为2至50个字符")
        private String contactName;

        @Schema(description = "联系人手机", example = "13567664888")
        @Pattern(regexp = "^\\d{4,11}$", message = "联系人电话为4至11位数字")
        private String contactMobile;

        @Schema(description = "联系人邮箱", example = "wangwu@qq.com")
        @Email(message = "联系人邮箱格式不正确")
        @Size(max = 100, message = "联系人邮箱长度不能超过100个字符")
        private String contactEmail;

        @Schema(description = "接收楼盘列表", example = "[\"海王星大厦\"]")
        private List<String> receiveProperties;
    }
}